#!/usr/bin/env node

const Koa = require('koa');//大写，类

const app = new Koa(),//实例化
      log = console.log;


app.use((ctx,next)=>{//M-logger
  log(`${ctx.method} ${ctx.path}`);
  next();//前面请求的信息，后面响应的封装
})

app.use((ctx,next)=>{  //M-ms
  const start = Date.now();
  next();
  const end = Date.now();
  log(`cost:${end-start}ms`);
})

app.use((ctx,next)=>{   //M-hello
  ctx.body = 'hello Koa';
});

app.listen(8080);




